package com.tsinghua.discharge.conf;

import com.tsinghua.discharge.common.TokenAuthorFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class filterConfig {
    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        TokenAuthorFilter tokenAuthorFilter = new TokenAuthorFilter();
        registrationBean.setFilter(tokenAuthorFilter);
        List<String> urlPatterns = new ArrayList<String>();
        urlPatterns.add("/user/logout.do");
        urlPatterns.add("/user/get_user_info.do");
        urlPatterns.add("/user/reset_password.do");
        urlPatterns.add("/user/updateUser.do");
        urlPatterns.add("/user/deleteUser.do");
        urlPatterns.add("/user/get_information.do");
        urlPatterns.add("/user/getUserInfoById.do");
        urlPatterns.add("/user/updateRole.do");
        urlPatterns.add("/user/getList.do");
        urlPatterns.add("/user/validatePass.do");
        urlPatterns.add("/upload/**");
        urlPatterns.add("/fileRecord/*");
        urlPatterns.add("/CalculateALparam/*");
        urlPatterns.add("/fileRecord/fileSectorRecordList.do/*");
        urlPatterns.add("/ConditionSelect/*");
        urlPatterns.add("/delete/*");
//        urlPatterns.add("/download/*");

        registrationBean.setUrlPatterns(urlPatterns);
        return registrationBean;
    }

}
